def getIntersectionNode(headA, headB):
    seen = set()
    p = headA
    while p:
        seen.add(p)
        print(p.val)
        p = p.next

    p = headB
    while p:
        print(2)
        if p in seen:
            return p
        p = p.next

    return None
